﻿using System.Windows;
using System.Windows.Media;
using Dsl.Ped.Common;
using Dsl.Ped.Desktop.Modules;

namespace Dsl.Ped.Desktop.ViewModels
{
    /// <summary>
    /// View model of a <see cref="IModule"/> that is loaded into DSLPed applicatoin
    /// </summary>
    public class ModuleViewModel : ViewModelBase
    {
        #region Fields

        /// <summary>
        /// Indicates wheter the module is visible
        /// </summary>
        private bool isVisible = true;

        /// <summary>
        /// Title of the module
        /// </summary>
        private string title = null;

        /// <summary>
        /// Content id of the module
        /// </summary>
        private string contentId = null;

        /// <summary>
        /// Indicates whether the module is selected
        /// </summary>
        private bool isSelected = false;

        /// <summary>
        /// Indicated whether the module is active
        /// </summary>
        private bool isActive = false;

        /// <summary>
        /// View of the module
        /// </summary>
        private FrameworkElement view = null;

        #endregion

        #region Constructors

        public ModuleViewModel(string name)
        {
            this.Name = name;
        }

        #endregion

        /// <summary>
        /// Gets the name of the module
        /// </summary>
        public string Name
        {
            get;
            private set;
        }

        /// <summary>
        /// Gets the <see cref="IconSource"/> of the modules
        /// </summary>
        public ImageSource IconSource
        {
            get;
            protected set;
        }

        /// <summary>
        /// Gets the value indicating whether the module is visible
        /// </summary>
        public bool IsVisible
        {
            get
            {
                return this.isVisible;
            }
            set
            {
                if (this.isVisible != value)
                {
                    this.isVisible = value;
                    RaisePropertyChanged(() => IsVisible);
                }
            }
        }

        /// <summary>
        /// Gets the title of the module
        /// </summary>
        public string Title
        {
            get
            {
                return this.title;
            }
            set
            {
                if (this.title != value)
                {
                    this.title = value;
                    RaisePropertyChanged(() => Title);
                }
            }
        }

        /// <summary>
        /// Gets the content id of the module
        /// </summary>
        public string ContentId
        {
            get
            {
                return this.contentId;
            }
            set
            {
                if (this.contentId != value)
                {
                    this.contentId = value;
                    RaisePropertyChanged(() => ContentId);
                }
            }
        }

        /// <summary>
        /// Gets the value indicating whehter the module is selected
        /// </summary>
        public bool IsSelected
        {
            get
            {
                return this.isSelected;
            }
            set
            {
                if (this.isSelected != value)
                {
                    this.isSelected = value;
                    RaisePropertyChanged(() => IsSelected);
                }
            }
        }

        /// <summary>
        /// Gets the value indicating whether the module is active
        /// </summary>
        public bool IsActive
        {
            get { return this.isActive; }
            set
            {
                if (this.isActive != value)
                {
                    this.isActive = value;
                    RaisePropertyChanged(() => IsActive);
                }
            }
        }

        /// <summary>
        /// Gets the view of the module
        /// </summary>
        public FrameworkElement View
        {
            get
            {
                return view;
            }
            set
            {
                view = value;
                RaisePropertyChanged(() => View);
            }
        }
    }
}
